function diff = J_pp_fun( m, param)
    % calculates J\prime\prime(m) 

    if param.K>0
        diff=(m>=param.m_l).*(m<param.m_h).*J_n_pp(m,param) ...
            +(m>=param.m_h).*(m<param.m_e).*J_r_pp(m,param) ...
            +(m>=param.m_e).*0;
    else 
        diff=J_n_pp(m,param).*(m>=param.m_l).*(m<param.m_h) ...
            +(m>=param.m_h).*0;    
    end

end